package be.artesis.titamo.webservice;

import java.util.List;

import be.artesis.titamo.io.SQLDatabase;
import be.artesis.titamo.io.TimeTableEntry;

public final class DataLayerWebService {

	private static String driver = "org.postgresql.Driver";
	private static String url = "jdbc:postgresql://127.0.0.1:5433/titamo";
	private static String username = "postgres";
	private static String password = "stay666off!";
	private static String tablename = "rooster";
	
	public DataLayerWebService()
	{
		
	}
	
	public static TimeTableEntry[] getRecordsByDocent(String docent, String dag)
	{
		SQLDatabase db = new SQLDatabase(driver, url, username, password, tablename);
		List<TimeTableEntry> records = db.getRecordsByDocent(docent, dag);
		return records.toArray(new TimeTableEntry[0]);
	}
	
	public static TimeTableEntry[] getErrors()
	{
		SQLDatabase db = new SQLDatabase(driver, url, username, password, tablename);
		List<TimeTableEntry> records = db.getErrors();
		return records.toArray(new TimeTableEntry[0]);
	}
	
	public static TimeTableEntry[] getRecordsByKlas(String klas, String dag)
	{
		SQLDatabase db = new SQLDatabase(driver, url, username, password, tablename);
		List<TimeTableEntry> records = db.getRecordsByKlas(klas, dag);
		return records.toArray(new TimeTableEntry[0]);
	}
	
	public static TimeTableEntry[] getRecordsByVak(String vak, String dag)
	{
		SQLDatabase db = new SQLDatabase(driver, url, username, password, tablename);
		List<TimeTableEntry> records = db.getRecordsByVak(vak, dag);
		return records.toArray(new TimeTableEntry[0]);
	}
}
